package router

import (
	"gitee.com/gopher2011/gin"
	"gitee.com/gopher2011/mall/app/api/admin"
	"gitee.com/gopher2011/mall/middleware"
)

func SmsCoupon(g *gin.RouterGroup) {
	r := g.Group("/coupon")
	{
		r.GET("/list", admin.SmsCoupon.List)
		r.POST("/create", admin.SmsCoupon.Add)
		r.GET("/:id", admin.SmsCoupon.GetItem) //获取单个优惠券的详细信息
		r.POST("/update/:id", admin.SmsCoupon.Update)
		r.POST("/delete/:id", admin.SmsCoupon.Delete)
	}
}

func SmsCouponHistory(g *gin.RouterGroup) {
	r := g.Group("/couponHistory")
	{
		r.GET("/list", admin.SmsCouponHistory.List)
	}
}

func SmsFlashPromotion(g *gin.RouterGroup) {
	r := g.Group("/flash")
	{
		r.GET("/list", admin.SmsFlashPromotion.List)
		r.POST("/update/status/:id", admin.SmsFlashPromotion.UpdateStatus)
		r.POST("/delete/:id", admin.SmsFlashPromotion.Delete)

		r.POST("/create", admin.SmsFlashPromotion.Create)
		r.POST("/update/:id", admin.SmsFlashPromotion.Update)

		r.GET("/:id", admin.SmsFlashPromotion.GetItem) //获取活动详情
	}
}

func SmsFlashPromotionProductRelation(g *gin.RouterGroup) {
	r := g.Group("/flash_product_relation")
	{
		r.GET("/delete/:id", admin.SmsFlashPromotionProductRelation.Delete)
		r.POST("/create", admin.SmsFlashPromotionProductRelation.Create)
		r.POST("/update/:id", admin.SmsFlashPromotionProductRelation.Update)
		r.GET("/list", admin.SmsFlashPromotionProductRelation.List)
		r.GET("/:id", admin.SmsFlashPromotionProductRelation.GetItem) //获取管理商品促销信息
	}
}

func SmsFlashPromotionSession(g *gin.RouterGroup) {
	r := g.Group("flash_session")
	{
		r.GET("/delete/:id", admin.SmsFlashPromotionSession.Delete)
		r.POST("/create", admin.SmsFlashPromotionSession.Create)
		r.POST("/update/:id", admin.SmsFlashPromotionSession.Update)
		r.POST("/update/status/:id", admin.SmsFlashPromotionSession.UpdateStatus)
		r.GET("/list", admin.SmsFlashPromotionSession.ListAll)
		r.GET("/select_list", admin.SmsFlashPromotionSession.List)
		r.GET("/:id", admin.SmsFlashPromotionSession.GetItem) //获取场次详情
	}
}

func SmsHomeAdvertise(g *gin.RouterGroup) {
	r := g.Group("/home/advertise")
	{
		r.POST("/delete", admin.SmsHomeAdvertise.Delete)
		r.POST("/create", admin.SmsHomeAdvertise.Create)
		r.POST("/update/:id", admin.SmsHomeAdvertise.Update)
		r.POST("/update/status/:id", admin.SmsHomeAdvertise.UpdateStatus)
		r.GET("/list", admin.SmsHomeAdvertise.List)
		r.GET("/:id", admin.SmsHomeAdvertise.GetItem)
	}
}

func SmsHomeBrand(g *gin.RouterGroup) {
	r := g.Group("/home/brand")
	{
		r.POST("/create", admin.SmsHomeBrand.Create)
		r.POST("/update/sort/:id", admin.SmsHomeBrand.UpdateSort)
		r.POST("/update/recommend_status", admin.SmsHomeBrand.UpdateRecommendStatus)
		r.POST("/delete", admin.SmsHomeBrand.Delete)
		r.GET("/list", admin.SmsHomeBrand.List)
	}
}

func SmsHomeNewProduct(g *gin.RouterGroup) {
	r := g.Group("/home/new_product")
	{
		r.GET("")
		r.POST("/create", admin.SmsHomeNewProduct.Create)
	}
}

func SmsHomeRecommendProduct(g *gin.RouterGroup) {
	r := g.Group("/home/recommend_product")
	{
		r.POST("/create", admin.SmsHomeRecommendProduct.Create)
		r.POST("/delete", admin.SmsHomeRecommendProduct.Delete)
		r.POST("/update/recommend_status", admin.SmsHomeRecommendProduct.UpdateRecommendStatus)
		r.POST("/update/sort/:id", admin.SmsHomeRecommendProduct.UpdateSort)
		r.GET("/list", admin.SmsHomeRecommendProduct.List)
	}
}

func SmsHomeRecommendSubject(g *gin.RouterGroup) {
	r := g.Group("/home/recommend_subject")
	{
		r.POST("/create", admin.SmsHomeRecommendSubject.Create)
		r.POST("/delete", admin.SmsHomeRecommendSubject.Delete)
		r.POST("/update/recommend_status", admin.SmsHomeRecommendSubject.UpdateRecommendStatus)
		r.POST("/update/sort/:id", admin.SmsHomeRecommendSubject.UpdateSort)
		r.GET("/list", admin.SmsHomeRecommendSubject.List)
	}
}

// 后台用户管理
func UmsAdmin(g *gin.RouterGroup) {
	r := g.Group("/admin")
	jwt, _ := middleware.Jwt()
	{
		r.POST("/login", jwt.LoginHandler)
		r.GET("/refresh_token", jwt.RefreshHandler)
		r.GET("/info", admin.UmsAdmin.GetAdminInfo)              // 获取当前登录用户信息
		r.POST("/logout")                                        // 登出功能
		r.GET("/list", admin.UmsAdmin.List)                      // 根据用户名或昵称分页获取用户列表
		r.POST("/register", admin.UmsAdmin.Register)             // 用户注册
		r.POST("/update/:id", admin.UmsAdmin.Update)             // 修改指定用户信息
		r.POST("/updateStatus/:id", admin.UmsAdmin.UpdateStatus) // 修改帐号状态
		r.POST("/delete/:id", admin.UmsAdmin.Delete)             // 删除指定用户信息
		r.GET("/role/:adminId", admin.UmsAdmin.GetRoleList)      // 获取指定用户的角色
		r.POST("/role/update", admin.UmsAdmin.UpdateRole)        //给用户分配角色

		r.POST("updatePassword", admin.UmsAdmin.UpdatePassword) //修改指定用户密码
		r.GET("/:id", admin.UmsAdmin.GetItem)                   // 获取指定用户信息
	}
}

func UmsMemberLevel(g *gin.RouterGroup) {
	r := g.Group("/memberLevel")
	{
		r.GET("/list", admin.UmsMemberLevel.List)
	}
}

// 后台菜单管理
func UmsMenu(g *gin.RouterGroup) {
	r := g.Group("menu")
	{
		r.POST("create", admin.UmsMenu.Create)                 // 添加后台菜单
		r.POST("update/:id", admin.UmsMenu.Update)             // 修改后台菜单
		r.DELETE("delete/:id", admin.UmsMenu.Delete)           // 根据ID删除后台菜单
		r.GET("list/:parentId", admin.UmsMenu.List)            // 分页查询后台菜单
		r.GET("treeList", admin.UmsMenu.TreeList)              // 树形结构返回所有菜单列表
		r.POST("updateHidden/:id", admin.UmsMenu.UpdateHidden) // 修改菜单显示状态
		r.GET("/:id", admin.UmsMenu.GetItem)                   // 根据ID获取菜单详情
	}
}

// 后台资源分类管理
func UmsResourceCategory(g *gin.RouterGroup) {
	r := g.Group("resourceCategory")
	{
		{
			r.GET("listAll", admin.UmsResourceCategory.ListAll)    // 查询所有后台资源分类
			r.POST("create", admin.UmsResourceCategory.Create)     // 添加后台资源分类
			r.POST("update/:id", admin.UmsResourceCategory.Update) // 修改后台资源分类
			r.POST("delete/:id", admin.UmsResourceCategory.Delete) // 根据ID删除后台资源
		}
	}
}

// 后台用户角色管理
func UmsRole(g *gin.RouterGroup) {
	r := g.Group("role")
	{
		r.POST("create", admin.UmsRole.Create)                    //添加角色
		r.POST("update/:id", admin.UmsRole.Update)                //修改角色
		r.POST("delete", admin.UmsRole.Delete)                    //批量删除角色
		r.GET("listAll", admin.UmsRole.ListAll)                   //获取所有角色
		r.GET("list", admin.UmsRole.List)                         //根据角色名称分页获取角色列表
		r.POST("updateStatus/:id", admin.UmsRole.UpdateStatus)    //修改角色状态
		r.GET("listMenu/:roleId", admin.UmsRole.ListMenu)         //获取角色相关菜单
		r.GET("listResource/:roleId", admin.UmsRole.ListResource) //获取角色相关资源
		r.POST("allocMenu", admin.UmsRole.AllocMenu)              //给角色分配菜单
		r.POST("allocResource", admin.UmsRole.AllocResource)      //给角色分配资源
	}
}

// 后台资源管理
func UmsResource(g *gin.RouterGroup) {
	r := g.Group("resource")
	{
		r.POST("create", admin.UmsResource.Create)     // 添加后台资源
		r.POST("update/:id", admin.UmsResource.Update) // 修改后台资源
		r.POST("delete/:id", admin.UmsResource.Delete) // 根据ID删除后台资源
		r.GET("list", admin.UmsResource.List)          // 分页模糊查询后台资源
		r.GET("listAll", admin.UmsResource.ListAll)    // 查询所有后台资源
		r.GET("/:id", admin.UmsResource.GetItem)       // 根据ID获取资源详情
	}
}

func CmsPreferenceArea(g *gin.RouterGroup) {
	r := g.Group("cms_preference_area")
	{
		r.GET("")
		r.POST("")
	}
}

func CmsSubject(g *gin.RouterGroup) {
	r := g.Group("cms_subject")
	{
		r.GET("")
		r.POST("")
	}
}

func OmsCompanyAddress(g *gin.RouterGroup) {
	r := g.Group("/companyAddress")
	{
		r.GET("/list")
		r.POST("")
	}
}

func OmsOrder(g *gin.RouterGroup) {
	r := g.Group("oms_order")
	{
		r.GET("")
		r.POST("")
	}
}

func OmsOrderReturnApply(g *gin.RouterGroup) {
	r := g.Group("oms_order_return_apply")
	{
		r.GET("")
		r.POST("")
	}
}

func OmsOrderReturnReason(g *gin.RouterGroup) {
	r := g.Group("oms_order_return_reason")
	{
		r.GET("")
		r.POST("")
	}
}

func OmsOrderSetting(g *gin.RouterGroup) {
	r := g.Group("oms_order_setting")
	{
		r.GET("")
		r.POST("")
	}
}

func PmsBrand(g *gin.RouterGroup) {
	r := g.Group("/brand")
	{
		r.GET("/list", admin.PmsBrand.List)
		r.POST("/create", admin.PmsBrand.Create)
		r.POST("/update/showStatus", admin.PmsBrand.UpdateShowStatus)
		r.POST("/update/factoryStatus", admin.PmsBrand.UpdateFactoryStatus)
		r.GET("/delete/:id", admin.PmsBrand.Delete)
		r.GET("/:id", admin.PmsBrand.GetItem)
		r.POST("/update/:id", admin.PmsBrand.Update)

		r.POST("/delete/batch", admin.PmsBrand.DeleteBatch)
		r.GET("/listAll", admin.PmsBrand.GetList)
	}
}

func PmsProductAttribute(g *gin.RouterGroup) {
	r := g.Group("/product_attribute")
	{
		r.GET("/:id", admin.PmsProductAttribute.GetItem)
		r.POST("/create", admin.PmsProductAttribute.Create)
		r.POST("/update/:id", admin.PmsProductAttribute.Update)
		r.POST("/delete", admin.PmsProductAttribute.Delete)
		r.GET("/list/:cid", admin.PmsProductAttribute.List)
		r.GET("/attrInfo/:product_category_id", admin.PmsProductAttribute.GetAttrInfo)
	}
}

func PmsProductAttributeCategory(g *gin.RouterGroup) {
	r := g.Group("/product_attribute/category")
	{
		r.GET("/:id", admin.PmsProductAttributeCategory.GetItem)
		r.POST("/create", admin.PmsProductAttributeCategory.Create)
		r.POST("/update/:id", admin.PmsProductAttributeCategory.Update)
		r.GET("/delete/:id", admin.PmsProductAttributeCategory.Delete)
		r.GET("/list/withAttr", admin.PmsProductAttributeCategory.GetListWithAttr)
		r.GET("/list", admin.PmsProductAttributeCategory.List)
	}
}

func PmsProductCategory(g *gin.RouterGroup) {
	r := g.Group("pms_product_category")
	{
		r.GET("")
		r.POST("")
	}
}

func PmsSkuStock(g *gin.RouterGroup) {
	r := g.Group("pms_sku_stock")
	{
		r.GET("")
		r.POST("")
	}
}
